package com.xzzz.backend.bsms.server.base.yuque.config;

import com.xzzz.backend.bsms.server.base.yuque.pojo.UserRes;
import com.xzzz.backend.bsms.server.base.yuque.YuqueFeign;
import com.xzzz.common.base.pojo.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;

@Slf4j
public class YuqueFeignFallbackFactory implements FallbackFactory<YuqueFeign> {

    @Override
    public YuqueFeign create(Throwable cause) {
        log.error(cause.getMessage());
        YuqueFeignFallback fallback = new YuqueFeignFallback();
        return fallback;
    }


    @Slf4j
    static class YuqueFeignFallback implements YuqueFeign {

        @Override
        public R<UserRes> user() {
            UserRes xzzz = new UserRes();
            xzzz.setId(1875939);
            xzzz.setName("小贼贼子");
            xzzz.setAvatar_url("https://cdn.nlark.com/yuque/0/2020/png/1875939/1609429628376-avatar/dfb7381f-8ae9-41d1-b860-2ae92113af4f.png");
            xzzz.setDescription("Java | Js |Go");
            return R.ok(xzzz);
        }
    }
}
